package com.power.services.helpInfo;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.power.dao.helpInfo.TiHelpInfoDAO;
import com.power.model.helpInfo.TiHelpInfo;

@Service("tiHelpInfoService")
public class TiHelpInfoServiceImpl implements TiHelpInfoService {

	@Autowired
	private TiHelpInfoDAO dao;

	public void create(TiHelpInfo hospital) {
		this.dao.save(hospital);
	}

	public TiHelpInfo read(Integer id) {
		return ((TiHelpInfo) this.dao.load(id));
	}

    public void saveOrUpdate(TiHelpInfo hospital) {
    	dao.saveOrUpdate(hospital);
    }

    public void delete(String ids){
        String[] idAry = ids.split("_");
        for (int i = 0; i < idAry.length; i++) {
            Integer id = new Integer(idAry[i]);
            dao.deleteByKey(id);
        }
    }

	public List<TiHelpInfo> findListByMemberId(Integer memberid) {
		DetachedCriteria criteria = DetachedCriteria.forClass(TiHelpInfo.class);
            criteria.add(Restrictions.like("memberid", memberid));
        return dao.findByCriteria(criteria);
	}

	public void delete(TiHelpInfo arg0) {
		dao.delete(arg0);
	}

	public void update(TiHelpInfo arg0) {
		dao.update(arg0);
	}

}